<?php 
class CBaseController extends CController
{	
	protected $templator;
	public function __construct(&$config=null) 
    { 
        parent::__construct($config);	
	} 
	
	public function init($tpl)
	{
		$this->templator=$tpl;		
		$this->templator->init();
		$this->templator->registerObject('tpl',$this);
	}
	
	public function getObject($obj)
	{
	 if(isset($obj)&&is_array($obj))	
		return parent::getObject($obj['p1']);
	 else if(isset($obj)&&is_string($obj))
		return parent::getObject($obj);
	 else
		return '';
	}
	
	public function reqLogin($flag=true)
	{
		if($flag)
		{
			$_user=parent::getObject('CurrentUser');
			if($_user->getIsGuest())
			{				
				$_user->getRequest()->redirect('login');
			}
		}
	}
	
}